package com.liuxin.zhiyuan.shujuzhongxin.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.liuxin.zhiyuan.shujuzhongxin.domain.po.MajorinfoEntity;
import com.liuxin.zhiyuan.shujuzhongxin.service.MajorinfoService;
import com.liuxin.common.utils.PageUtils;
import com.liuxin.common.utils.R;



/**
 * 本科专业详细信息表
 *
 * @author zsl
 * @email 1301966496@qq.com
 * @date 2025-10-13 23:02:17
 */
@RestController
@RequestMapping("shujuzhongxin/majorinfo")
public class MajorinfoController {
    @Autowired
    private MajorinfoService majorinfoService;


    /**
     * 查询专业树列表
     */
    @RequestMapping("/listtree")
    //@RequiresPermissions("shujuzhongxin:majorinfo:list")
    public R listTree(@RequestParam(required = false) String level){
        PageUtils page = majorinfoService.listWithTree(level);
        return R.ok().put("data", page);
    }


    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("shujuzhongxin:majorinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = majorinfoService.queryMajorInfoPage(params);
        return R.ok().put("data", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info")
    //@RequiresPermissions("shujuzhongxin:majorinfo:info")
    public R info(@RequestParam("id") Integer id){
		MajorinfoEntity majorinfo = majorinfoService.getById(id);
        return R.ok().put("data", majorinfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("shujuzhongxin:majorinfo:save")
    public R save(@RequestBody MajorinfoEntity majorinfo){
		majorinfoService.save(majorinfo);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
   //@RequiresPermissions("shujuzhongxin:majorinfo:update")
    public R update(@RequestBody MajorinfoEntity majorinfo){
		majorinfoService.updateById(majorinfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("shujuzhongxin:majorinfo:delete")
    public R delete(@RequestBody Integer[] ids){
		majorinfoService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
